package com.jhl.seckill.mq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MQSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    //    发送秒杀消息
    public void sendSeckillMessage(String msg) {
        log.info("发送消息：" + msg);
//        根据路由key将消息发送给交换机
        rabbitTemplate.convertAndSend("seckillExchange", "seckill.message", msg);

    }
}
